﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace checkbox_MDI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 添加窗体
        /// 在C# WinForm中，通过new Form3()创建MDI子窗体时，每次调用都会生成新的对象实例。即使变量名同为F3，但每次执行生成窗体ToolStripMenuItem_Click方法时，该变量仅在当前作用域内有效，实际每次都会在堆内存中创建新的Form3实例‌
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 生成窗体ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 F2 = new Form2();
            F2.MdiParent = this;
            F2.Show();
            Form3 F3 = new Form3();
            F3.MdiParent = this;
            F3.Show();
            Form4 F4 = new Form4();
            F4.MdiParent = this;
            F4.Show();
        }
        /// <summary>
        /// 设计MDI窗体的排列顺序横向排列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 横向排列ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }
        /// <summary>
        /// 设计MDI窗体的排列顺序竖向排列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 竖向排列ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }
    }
}
